
from _spice_path import spice_path

def _getpos(spiceref,motorname):
    motorglobal=spiceref.GetVIReference(spice_path + '\\common\\globals\\motor_globals.vi')
    searchvi=spiceref.GetVIReference(spice_path + '\\common\\Utilities\\device_utilities\\SearchMotorListByNameOrAlias.vi')
    parnames='Motor','Device Index','Motor Index','found?'
    parvalues=motorname,0,0,0
    searchnames,searchvalues=searchvi.Call(parnames,parvalues)
    motorindexvalue=searchvalues[2]
    motorpositions=motorglobal.GetControlValue('Motor Positions')
    motorvalue=motorpositions[motorindexvalue]
    return motorvalue
